package org.example.aidemo.controller;

import org.apache.ibatis.annotations.Param;
import org.example.aidemo.pojo.Result;
import org.example.aidemo.pojo.UserMemo;
import org.example.aidemo.service.UserMemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/memo")
public class UserMemoController {
    @Autowired
    private UserMemoService userMemoService;
    @GetMapping("/getUserMemoByUserId")
    public Result<List<UserMemo>> getUserMemoByUserId(@Param("UserId") Long UserId) {
        Result<List<UserMemo>> result = new Result<>();
        result.setData(userMemoService.getUserMemoByUserId(UserId));
        result.setCode("200");
        result.setMsg("请求成功！");
        return result;
    }
    @DeleteMapping("/deleteUserMemo/{ids}")
    public Result<String> deleteUserMemo(@PathVariable("ids") List<Long> ids) {
        Result<String> result = new Result<>();
        userMemoService.deleteUserMemo(ids);
        result.setCode("200");
        result.setMsg("删除成功！");
        return result;
    }
    @PostMapping("/addUserMemo")
    public Result<UserMemo> addUserMemo(@RequestBody String memo) {
        Result<UserMemo> result = new Result<>();
        UserMemo userMemo = userMemoService.addUserMemo(memo);
        result.setData(userMemo);
        result.setCode("200");
        result.setMsg("添加成功！");
        return result;
    }
}
